package com.imddysc.dwz.utils;

import java.io.Serializable;

import org.omg.CORBA.PUBLIC_MEMBER;

public class Result implements Serializable {

	private static final long serialVersionUID = 1;
	
	private Integer code;
	private String message;
	private Object data;
	
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	
	public Result() {
	}
	
	public Result(Integer code, String message, Object data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}

	public void setResultCode(ResultCode resultCode) {
		this.code = resultCode.code();
		this.message = resultCode.message();
	}
	
	public static Result success() {
		Result result = new Result();
		result.setResultCode(ResultCode.SUCCESS);
		return result;
	}
	
	public static Result success(Object data) {
		Result result = new Result();
		result.setResultCode(ResultCode.SUCCESS);
		result.setData(data);
		return result;
	}
	
	public static Result failure() {
		Result result = new Result();
		result.setResultCode(ResultCode.FAILURE);
		return result;
	}
	
	public static Result failure(Object data) {
		Result result = new Result();
		result.setResultCode(ResultCode.FAILURE);
		result.setData(data);
		return result;
	}
	
	public static Result resultCodeMessage(ResultCode resultCode) {
		Result result = new Result();
		result.setResultCode(resultCode);
		return result;
	}
	
	public static Result resultCodeMessageData(ResultCode resultCode, Object data) {
		Result result = new Result();
		result.setResultCode(resultCode);
		result.setData(data);
		return result;
	}
	
	public static Result resultCodeMessage(Integer code, String message) {
		Result result = new Result();
		result.setCode(code);
		result.setMessage(message);
		return result;
	}
	
	public static Result resultCodeMessageData(Integer code, String message, Object data) {
		Result result = new Result();
		result.setCode(code);
		result.setMessage(message);
		result.setData(data);
		return result;
	}
	
	
}
